import { Entity, PrimaryGeneratedColumn, Column, OneToOne, JoinColumn,  } from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";
import { CharacterEntity } from "./character.entity";

@Entity("character_attributes")
@ManualTimestamp()
export class CharacterAttributeEntity {
  @PrimaryGeneratedColumn()
  id!: number;

  @Column("int", { name: "characterId" })
  characterId!: number;

  @Column("int", { default: 300, comment: "当前生命值" })
  hp!: number;

  @Column("int", { default: 300, comment: "最大生命值" })
  maxHp!: number;

  @Column("int", { default: 100, comment: "当前法力值" })
  mp!: number;

  @Column("int", { default: 100, comment: "最大法力值" })
  maxMp!: number;

  @Column("int", { default: 80, comment: "攻击力" })
  ap!: number;

  @Column("int", { default: 40, comment: "防御力" })
  df!: number;

  @Column("int", { default: 10, comment: "速度" })
  sp!: number;

  @Column("int", { default: 0, comment: "当前负重" })
  weight!: number;

  @Column("int", { default: 100, comment: "最大负重" })
  maxWeight!: number;

  @Column("int", { default: 100, comment: "活力值" })
  hyd!: number;

  @Column("int", { default: 100, comment: "体力值" })
  sinew!: number;

  @Column("int", { default: 0, comment: "剩余属性点" })
  p!: number;

  @Column("varchar", {
    length: 8,
    default: "一",
    comment: "速度字符串(一,二,三,四,五,六,七,八,九)",
  })
  speedStr!: string;

  @Column("datetime", {
    name: "updated_at",
    nullable: true,
    comment: "更新时间",
  })
  updated_at!: Date;

  // 关联关系
  @OneToOne(() => CharacterEntity, (character) => character.attributes)
  @JoinColumn({ name: "characterId" })
  character!: CharacterEntity;
}
